﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CCWin;

namespace EHR18
{
    public partial class FrmBase : CCWin.Skin_VS
    {
        public FrmBase()
        {
            InitializeComponent();
        }
        public void HideAllMdi()
        {
            foreach (var frm in MdiChildren)
            {
                frm.Hide();
            }
        }
        public void ShowMdiChildren(Form frmChild)
        {
            foreach (var frm in MdiChildren)
            {
                if (frm.Text == frmChild.Text)
                {
                    if (ActiveMdiChild.Text == frmChild.Text)
                        return;
                    frmChild.Show();
                    return;
                }
                else
                {
                    frm.Hide();
                }
            }
            AddMdiChildren(frmChild);
        }
        public void AddMdiChildren(Form frmChild)
        {
            frmChild.TopLevel = false;
            frmChild.FormBorderStyle = FormBorderStyle.None;
            frmChild.MdiParent = this;
            frmChild.Dock = DockStyle.Fill;
            frmChild.Show();
        }

        public void ShowInControl(Control Parent, Form Child)
        {

            var c = Parent.Controls.Find(Child.Name, true);
            Control control;
            foreach(Control a in Parent.Controls)
            {
                a.Hide();
            }
            if (c != null && c.Length > 0)
            {
                control = c[0];
            }
            else
            {
               
                Child.Parent = Parent;
                control = Child;
                control.Dock = DockStyle.Fill;
            }
            control.BringToFront();
            control.Show();
        }
    }
}
